BlueSpray - Help
© SchoonerTurtles, Inc. 2012-2015

Introduction
Contents
Getting Started
Download
Navigating
Tutorials
Scripting
Advanced
About

Writing Extensions

Reading and Writing Properties

Any objects with proprety values should override GetProperties() and SetProperties() to read and write their property values. This is accomplished by providing a Key/Value pair that is writting to an XML tags attributes and then read back when the object's properties are imported.

Objects that contain other objects should also override GetContainedObjectsProperties() and SetContainedObjectProperties() to read and write the properties for those objects.

You should not use the following key values (names of attributes/properties):

  • Name - this is the name of the overall object and can be used to identify an object on loading. It is automatically writtin out if available.
  • ContainedClassName - this is the name of the class writing the propery

GetProperties()

if (NewDocument!=true) TheSettings.Add("NewDocument",NewDocument);

SetProperties()

NewDocument=TheSettings.Get("NewDocument",NewDocument);

GetContainedObjectsProperties()

Override this function to write contained objects into the XML string.

public String GetContainedObjectsProperties(int TheLevel) throws Exception
{
String TheContent="";

TheContent=super.GetContainedObjectsProperties(TheLevel);

if (TheDefaultStyle!=null) TheContent=TheDefaultStyle.WriteToSTX(TheContent, TheLevel);

return(TheContent);
}

SetContainedObjectProperties()

Below is a sample of overriding this function for a class that contains other objects. The ContainerClassName should match this classes simple name. The ContainedObjectClassName can be used to determine the type of object to create while ObjectName can be used to distinguish between different objects of the same type in the same class.

public int SetContainedObjectProperties(String ContainedObjectClassName,String ContainerClassName,
String ObjectName,String TheString,int IndexStart) throws Exception
{
if (ContainedObjectClassName.equals(STStyle.class.getSimpleName()))
{
STStyle Temp=new STStyle();

IndexStart=Temp.LoadFromString(TheString, IndexStart);

if (Temp.GetName().equals("DefaultStyle")) TheDefaultStyle=Temp;
else IndexStart=super.SetContainedObjectProperties(ContainedObjectClassName,ContainerClassName,ObjectName,TheString,IndexStart);

return(IndexStart);
}